﻿package com.shangda.frame;
import java.nio.channels.SocketChannel;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.TimerTask;


public class TimeOclock extends TimerTask{

	private SimpleDateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss");
	private SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
	
	private MainFrame mainFrame;
	
	public TimeOclock(MainFrame mainFrame){
		this.mainFrame = mainFrame;
	}
	
	
	public void run() {
		String time = dateFormatter.format(Calendar.getInstance().getTime());
		mainFrame.getTimeField().setText(time);
		String nowTime = date.format(Calendar.getInstance().getTime());
		mainFrame.getDateField().setText(nowTime);
	}
	
	
}
